package evolution;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.Reader;

import evolution.changelog.ChangeLogEntry;


public class ChangeLogReader
{
	private BufferedReader reader;

	public ChangeLogReader(Reader reader)
	{
		this.reader = new BufferedReader(reader);
	}

	public ChangeLogEntry nextEntry() throws IOException
	{
		ChangeLogEntry result = new ChangeLogEntry();
		String line = reader.readLine();
		if (line == null)
		{
			return null;
		}
		while (line != null)
		{
			if (line.trim().length() == 0)
			{
				break;
			}
			int colon = line.indexOf(':');
			result.addHeader(line.substring(0, colon).trim(), line.substring(colon + 1).trim());
			line = reader.readLine();
		}
		return result;
	}

}
